<?php

    function mydate($date)
    {
       $day=substr($date,8,2);
       $mymonth = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
       $month=substr($date,5,2);
       $year=substr($date,0,4);
       $temp=$day.' '.$mymonth[$month-1].' '.$year;
       return $temp;
    }

    if(!empty($jobs))
    {
        echo "<table cellpadding=0 cellspacing=0 style='border:none' class='mytable'>";
            echo "<tr><th width='40px'>ID</th> <th width='240px'>Position</th><th width='240px'>Company</th><th width='120px'>Location</th><th width='120px'>Created</th><th width='175px'>Status</th><th width='175px'>Action</th></tr>";
            foreach($jobs as $data)
            {
                echo "<td>".$data['jobs']['id']."</td>";
                //echo "<td>".$data['jobs']['position']."</td>";
                echo "<td><a href='javascript:view_job(".$data['jobs']['id'].")' class='sky'>".$data['jobs']['position']."</a></td>";
                
                echo "<td>".$data['employers']['company_name']."</td>";
                echo "<td>".$data['cities']['name']."</td>";
                echo "<td>".mydate($data['jobs']['created'])."</td>";
                echo "<td>";
                if($data['jobs']['status']==1)
                {   
                    if($data['jobs']['end_date'] < date("Y-m-d") )
                    { echo " Expired "; }
                    else
                    { echo " Published "; }
                    echo " <br> ";
                    echo mydate($data['jobs']['end_date']); 
                }
                else
                { 
                    if($data['jobs']['slip']!='')
                    { 
                        echo "Waiting Approval";
                        echo "<br>";
                        echo $ajax->link('[ Slip ]',
                                            array('controller'=>'jobs','action'=>'slip_admin',$data['jobs']['id']),
                                            array('update'=>'slip','class'=>'sky','complete'=>"make_slip();")
                                         );                                                                   
                        echo "&nbsp";
                        echo $ajax->link('[ Approve ]',
                                            array('controller'=>'jobs','action'=>'approve_admin',$data['jobs']['id']),
                                            array('update'=>'result','class'=>'sky')
                                         );                                                                   
                        
                        
                    }
                    else
                    { echo " Waiting Payment "; }
                }
                echo "</td>";
                echo "<td>";
                echo $ajax->link('[ Edit ]',
                                    array('controller'=>'jobs','action'=>'edit_admin',$data['jobs']['id']),
                                    array('update'=>'slip','class'=>'sky','complete'=>"make_slip();")
                                 );            
                echo "&nbsp";
                echo $ajax->link('[ Delete ]', 
                        array('controller' => 'jobs', 'action' => 'delete_admin',$data['jobs']['id']),
                        array('update' => 'result','class'=>'sky'),
                        "Are you sure ?"
                        );                           
                
                echo "</td>";
            echo "</tr>";
            }
            echo "<tr class='end'><td class='end' colspan=7> &nbsp </td></tr>";
        echo "</table>";            
    }
    else
    { echo "<span class='red'>Sorry, there is no data in this category</span>"; }
    echo "<div id='slip'></div>";  
?>